Skip to content

Conversation

Xyedo
Copy link

@Xyedo Xyedo commented Aug 4, 2025

Fixes: #1146
it also make it migrating from #[sqlx(default)] to scylladb #[scylla(allow_missing)] smoothly

Pre-review checklist

  • I have split my patch into logically separate commits.
  • All commit messages clearly explain what they change and why.
  • I added relevant tests for new features and bug fixes.
  • All commits compile, pass static checks and pass test.
  • PR description sums up the changes and reasons why they should be introduced.
  • I have provided docstrings for the public items that I want to introduce.
  • I have adjusted the documentation in ./docs/source/.
  • I added appropriate Fixes: annotations to PR description.

@Xyedo Xyedo force-pushed the partial-DeserializeValue branch from 67e73b9 to 820386a Compare August 4, 2025 10:34
@github-actions github-actions bot added the semver-checks-breaking cargo-semver-checks reports that this PR introduces breaking API changes label Aug 4, 2025
Copy link

github-actions bot commented Aug 4, 2025

cargo semver-checks detected some API incompatibilities in this PR.
Checked commit: 74184aa

See the following report for details:

cargo semver-checks output
./scripts/semver-checks.sh --baseline-rev c622e73fa2c61a586dfa0aff610afae00ee78a5a
+ cargo semver-checks -p scylla -p scylla-cql --baseline-rev c622e73fa2c61a586dfa0aff610afae00ee78a5a
     Cloning c622e73fa2c61a586dfa0aff610afae00ee78a5a
    Building scylla v1.3.1 (current)
       Built [  43.664s] (current)
     Parsing scylla v1.3.1 (current)
      Parsed [   0.113s] (current)
    Building scylla v1.3.1 (baseline)
error: running cargo-doc on crate 'scylla' failed with output:
-----
   Compiling libc v0.2.175
   Compiling proc-macro2 v1.0.101
   Compiling unicode-ident v1.0.18
   Compiling find-msvc-tools v0.1.1
   Compiling shlex v1.3.0
   Compiling autocfg v1.5.0
    Checking cfg-if v1.0.3
   Compiling dunce v1.0.5
   Compiling fs_extra v1.3.0
   Compiling num-traits v0.2.19
    Checking pin-project-lite v0.2.16
   Compiling quote v1.0.40
   Compiling syn v2.0.106
   Compiling getrandom v0.3.3
   Compiling jobserver v0.1.34
   Compiling cc v1.2.36
    Checking once_cell v1.21.3
   Compiling pkg-config v0.3.32
   Compiling vcpkg v0.2.15
    Checking zeroize v1.8.1
   Compiling cmake v0.1.54
   Compiling aws-lc-rs v1.13.3
   Compiling fnv v1.0.7
   Compiling zerocopy v0.8.27
   Compiling ident_case v1.0.1
   Compiling strsim v0.11.1
   Compiling aws-lc-sys v0.30.0
   Compiling openssl-sys v0.9.109
    Checking num-integer v0.1.46
    Checking socket2 v0.6.0
    Checking mio v1.0.4
    Checking futures-sink v0.3.31
    Checking futures-core v0.3.31
   Compiling libm v0.2.15
    Checking bytes v1.10.1
    Checking futures-channel v0.3.31
    Checking rand_core v0.9.3
    Checking rustls-pki-types v1.12.0
   Compiling lock_api v0.4.13
   Compiling synstructure v0.13.2
   Compiling darling_core v0.20.11
   Compiling bigdecimal v0.4.8
   Compiling num-bigint v0.3.3
    Checking untrusted v0.9.0
    Checking pin-utils v0.1.0
   Compiling thiserror v1.0.69
   Compiling rustls v0.23.31
    Checking memchr v2.7.5
    Checking slab v0.4.11
    Checking futures-io v0.3.31
   Compiling snap v1.1.1
   Compiling tokio-macros v2.5.0
   Compiling futures-macro v0.3.31
    Checking tokio v1.47.1
   Compiling zerofrom-derive v0.1.6
   Compiling darling_macro v0.20.11
   Compiling thiserror v2.0.16
    Checking powerfmt v0.2.0
    Checking foreign-types-shared v0.1.1
    Checking futures-task v0.3.31
   Compiling openssl v0.10.73
   Compiling crossbeam-utils v0.8.21
   Compiling parking_lot_core v0.9.11
    Checking futures-util v0.3.31
    Checking zerofrom v0.1.6
    Checking foreign-types v0.3.2
    Checking deranged v0.5.3
   Compiling darling v0.20.11
   Compiling yoke-derive v0.8.0
   Compiling thiserror-impl v1.0.69
   Compiling thiserror-impl v2.0.16
   Compiling openssl-macros v0.1.1
    Checking ppv-lite86 v0.2.21
    Checking num-bigint v0.4.6
    Checking iana-time-zone v0.1.63
    Checking bitflags v2.9.4
    Checking twox-hash v2.1.2
    Checking subtle v2.6.1
    Checking stable_deref_trait v1.2.0
    Checking num-conv v0.1.0
    Checking either v1.15.0
    Checking time-core v0.1.6
    Checking smallvec v1.15.1
    Checking log v0.4.28
   Compiling tokio-openssl v0.6.5
    Checking scopeguard v1.2.0
    Checking time v0.3.43
    Checking itertools v0.14.0
    Checking yoke v0.8.0
    Checking lz4_flex v0.11.5
    Checking chrono v0.4.42
    Checking rand_chacha v0.9.0
    Checking futures-executor v0.3.31
   Compiling scylla-macros v1.3.1 (/home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-c622e73fa2c61a586dfa0aff610afae00ee78a5a/db47635dde0f72253839ed81083b835732171aa4/scylla-macros)
   Compiling tracing-attributes v0.1.30
    Checking uuid v1.18.1
    Checking secrecy v0.8.0
    Checking tracing-core v0.1.34
    Checking hashbrown v0.14.5
    Checking byteorder v1.5.0
    Checking allocator-api2 v0.2.21
    Checking equivalent v1.0.2
    Checking foldhash v0.1.5
    Checking tracing v0.1.41
    Checking dashmap v6.1.0
    Checking hashbrown v0.15.5
    Checking scylla-cql v1.3.1 (/home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-c622e73fa2c61a586dfa0aff610afae00ee78a5a/db47635dde0f72253839ed81083b835732171aa4/scylla-cql)
    Checking futures v0.3.31
    Checking histogram v0.11.3
    Checking rand v0.9.2
   Compiling async-trait v0.1.89
    Checking rand_pcg v0.9.0
    Checking socket2 v0.5.10
    Checking arc-swap v1.7.1
    Checking rustls-webpki v0.103.4
    Checking tokio-rustls v0.26.2
 Documenting scylla v1.3.1 (/home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-c622e73fa2c61a586dfa0aff610afae00ee78a5a/db47635dde0f72253839ed81083b835732171aa4/scylla)
�[38;5;9merror: couldn't read `/home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-c622e73fa2c61a586dfa0aff610afae00ee78a5a/db47635dde0f72253839ed81083b835732171aa4/scylla/src/deserialize/README.md`: No such file or directory (os error 2)
   �[38;5;12m--> /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-c622e73fa2c61a586dfa0aff610afae00ee78a5a/db47635dde0f72253839ed81083b835732171aa4/scylla/src/lib.rs:203:14
    �[38;5;12m|
�[38;5;12m203 �[38;5;12m|     #![doc = include_str!("deserialize/README.md")]
    �[38;5;12m|              �[38;5;9m^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: could not document `scylla`

-----

error: failed to build rustdoc for crate scylla v1.3.1
note: this is usually due to a compilation error in the crate,
      and is unlikely to be a bug in cargo-semver-checks
note: the following command can be used to reproduce the compilation error:
      cargo new --lib example &&
          cd example &&
          echo '[workspace]' >> Cargo.toml &&
          cargo add --path /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-c622e73fa2c61a586dfa0aff610afae00ee78a5a/db47635dde0f72253839ed81083b835732171aa4/scylla --features bigdecimal-04,chrono-04,default,full-serialization,metrics,num-bigint-03,num-bigint-04,openssl-010,rustls-023,secrecy-08,time-03 &&
          cargo check

    Building scylla-cql v1.3.1 (current)
       Built [  10.639s] (current)
     Parsing scylla-cql v1.3.1 (current)
      Parsed [   0.036s] (current)
    Building scylla-cql v1.3.1 (baseline)
       Built [  10.190s] (baseline)
     Parsing scylla-cql v1.3.1 (baseline)
      Parsed [   0.036s] (baseline)
    Checking scylla-cql v1.3.1 -> v1.3.1 (no change; assume patch)
     Checked [   0.382s] 165 checks: 165 pass, 13 skip
     Summary no semver update required
    Finished [  22.242s] scylla-cql
error: aborting due to failure to build rustdoc for crate scylla v1.3.1

Stack backtrace:
   0: anyhow::error::<impl anyhow::Error>::msg
   1: anyhow::__private::format_err
   2: cargo_semver_checks::data_generation::generate::generate_rustdoc
   3: cargo_semver_checks::data_generation::request::CrateDataRequest::resolve
   4: cargo_semver_checks::rustdoc_gen::StatefulRustdocGenerator<cargo_semver_checks::rustdoc_gen::ReadyState>::load_rustdoc
   5: cargo_semver_checks::Check::check_release
   6: cargo_semver_checks::exit_on_error
   7: cargo_semver_checks::main
   8: std::sys::backtrace::__rust_begin_short_backtrace
   9: main
make: *** [Makefile:73: semver-rev] Error 1

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds an allow_missing attribute to struct fields for both row and value deserialization, allowing fields to be initialized with Default::default() when missing from the database instead of failing. This feature provides compatibility with sqlx's #[sqlx(default)] attribute for smoother migration to scylla-rust-driver.

  • Implements #[scylla(allow_missing)] attribute for both struct-level and field-level usage
  • Adds support for the attribute in both row and value deserialization contexts
  • Includes comprehensive test coverage for the new functionality

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
scylla-macros/src/lib.rs Adds documentation for the new allow_missing attribute
scylla-macros/src/serialize/value.rs Adds ignored allow_missing attribute parsing for value serialization
scylla-macros/src/serialize/row.rs Adds ignored allow_missing attribute parsing for row serialization
scylla-macros/src/deserialize/value.rs Implements allow_missing logic for value deserialization
scylla-macros/src/deserialize/row.rs Implements allow_missing logic for row deserialization
scylla/tests/integration/macros/hygiene.rs Adds hygiene tests for the new attribute
scylla-cql/src/deserialize/row_tests.rs Adds comprehensive tests for allow_missing functionality

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

/// column into the first field, second column into the second field and so on.
/// It will still still verify that the column types and field types match.
///
/// #[(scylla(allow_missing))]
Copy link

Copilot AI Aug 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space after # - should be /// #[scylla(allow_missing)]

Suggested change
/// #[(scylla(allow_missing))]
/// #[scylla(allow_missing)]

Copilot uses AI. Check for mistakes.

Copy link
Author

@Xyedo Xyedo Sep 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in the latest commit

/// to a column with the same name. This attribute allows to match to a column
/// with provided name.
///
/// #[(scylla(allow_missing))]
Copy link

Copilot AI Aug 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space after # - should be /// #[scylla(allow_missing)]

Suggested change
/// #[(scylla(allow_missing))]
/// #[scylla(allow_missing)]

Copilot uses AI. Check for mistakes.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in the latest commit

@Xyedo Xyedo force-pushed the partial-DeserializeValue branch from 820386a to 7091295 Compare September 1, 2025 09:52
add allow_missing with macro DeserializeRow,
add allow_missing in the struct attributes to handle partial deserialization and
make it easier instead of defining on each struct field
@Xyedo Xyedo force-pushed the partial-DeserializeValue branch from 7091295 to 74184aa Compare September 9, 2025 02:56
Copy link
Collaborator

@Lorak-mmk Lorak-mmk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay! Please rebase on main to make semver checks work again.

Comment on lines +185 to +189
#[test]
fn test_struct_deserialization_loose_ordering_allow_missing() {
#[derive(DeserializeRow, PartialEq, Eq, Debug)]
#[scylla(crate = "crate")]
#[scylla(allow_missing)]
Copy link
Collaborator

@Lorak-mmk Lorak-mmk Oct 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please let's do one thing in this PR. Other field attributes can't be used on a struct, so let's remove this ability from this one as well, at least for now. It will also simplify this PR a lot.

@Lorak-mmk Lorak-mmk added the waiting-on-author Waiting for a response from issue/PR author label Oct 16, 2025
/// If set, the generated implementation will not verify the column names at
/// all. Because it only works with `enforce_order`, it will deserialize first
/// column into the first field, second column into the second field and so on.
/// It will still still verify that the column types and field types match.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🏕️ Unrelated to this PR - typo: still still -> still.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

semver-checks-breaking cargo-semver-checks reports that this PR introduces breaking API changes waiting-on-author Waiting for a response from issue/PR author

Projects

None yet

Development

Successfully merging this pull request may close these issues.

How to do partial deserialization

3 participants